//
//  HEditViewController.m
//  SCM
//
//  Created by Zhen Huang on 17/5/8.
//  Copyright © 2017年 huangzhen. All rights reserved.
//

#import "HEditViewController.h"
#import "HLogin.h"
#import "UserDefault.h"
#import "Networking.h"
#import "Model_Hr_Scheduling.h"
#import "Model_Hr_Scheduling_Dept.h"
#import "InitDbTable.h"
#import "Model_Pub_Department_Nurse.h"
@interface HEditViewController ()
@property (nonatomic, strong) UIButton *SCDButton;
@property (nonatomic, strong) HOwner *model;
@property (nonatomic, strong) UIButton *ligouButton;
@property (nonatomic, strong) UIButton *PeopleButton;
@property (nonatomic, strong) UIButton *JDButton;//查看用户权限科室排班
@property (nonatomic, strong) UIButton *JDSButton;//查看科室排班
@property (nonatomic, strong) NSMutableArray *letterArray;
@property (nonatomic, strong) NSMutableArray *modelArray;
@property (nonatomic, strong) NSMutableArray *dataArray;

@end

@implementation HEditViewController
- (instancetype)init
{
    if (self) {
        self.letterArray = [NSMutableArray new];
        self.modelArray = [NSMutableArray new];
        self.dataArray = [NSMutableArray new];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.barTintColor =kNavBlueColor;
    self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]};
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.JDButton];
    [self.view addSubview:self.SCDButton];
    [self.view addSubview:self.PeopleButton];
    [self.view addSubview:self.JDSButton];
    [self.view addSubview:self.ligouButton];
    self.model = [UserDefault getUserInfo];
}
- (UIButton *)JDButton
{
    if (!_JDButton) {
        _JDButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _JDButton.frame = CGRectMake(20, 240, ScreenWidth - 40, 40);
        _JDButton.backgroundColor = RGB(13, 140, 236);
        _JDButton.layer.masksToBounds = YES;
        _JDButton.layer.cornerRadius = 7;
        [_JDButton setTitle:@"更新科室权限" forState:UIControlStateNormal];
        [_JDButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _JDButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [_JDButton addTarget:self action:@selector(handleclickJD:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _JDButton;
}
- (UIButton *)PeopleButton
{
    if (!_PeopleButton) {
        _PeopleButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _PeopleButton.frame = CGRectMake(20, self.JDButton.bottom + 20, ScreenWidth - 40, 40);
        _PeopleButton.backgroundColor = RGB(13, 140, 236);
        _PeopleButton.layer.masksToBounds = YES;
        _PeopleButton.layer.cornerRadius = 7;
        [_PeopleButton setTitle:@"更新个人排班" forState:UIControlStateNormal];
        [_PeopleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _PeopleButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [_PeopleButton addTarget:self action:@selector(handleclickPeople:) forControlEvents:UIControlEventTouchUpInside];

    }
    return _PeopleButton;
}
- (UIButton *)SCDButton
{
    if (!_SCDButton) {
        _SCDButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _SCDButton.frame = CGRectMake(20, self.PeopleButton.bottom + 20, ScreenWidth-40, 40);
        _SCDButton.backgroundColor = RGB(13, 140, 236);
        _SCDButton.layer.masksToBounds = YES;
        _SCDButton.layer.cornerRadius = 7;
        [_SCDButton setTitle:@"更新通讯录" forState:UIControlStateNormal];
        [_SCDButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _SCDButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [_SCDButton addTarget:self action:@selector(handleclick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _SCDButton;
}
- (UIButton *)JDSButton
{
    if (!_JDSButton) {
        _JDSButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _JDSButton.frame = CGRectMake(20, self.SCDButton.bottom + 20, ScreenWidth - 40, 40);
        _JDSButton.backgroundColor = RGB(13, 140, 236);
        _JDSButton.layer.masksToBounds = YES;
        _JDSButton.layer.cornerRadius = 7;
        [_JDSButton setTitle:@"更新科室排班" forState:UIControlStateNormal];
        [_JDSButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _JDSButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [_JDSButton addTarget:self action:@selector(handleclickSJD:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _JDSButton;
}

- (UIButton *)ligouButton
{
    if (!_ligouButton) {
        _ligouButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _ligouButton.frame = CGRectMake(20, self.JDSButton.bottom + 20, ScreenWidth-40, 40);
        _ligouButton.backgroundColor = RGB(13, 140, 236);
        _ligouButton.layer.masksToBounds = YES;
        _ligouButton.layer.cornerRadius = 7;
        [_ligouButton setTitle:@"退出登录" forState:UIControlStateNormal];
        [_ligouButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _ligouButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [_ligouButton addTarget:self action:@selector(handleclickOUT:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _ligouButton;
}






 - (void)handleclickOUT:(UIButton *)sender
{
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"是否注销登录?"
                                                    message:nil
                                                   delegate:nil
                                          cancelButtonTitle:@"取消"
                                          otherButtonTitles:@"确定", nil];
    [alert show];
    alert.tag = 200;
    alert.delegate = self;
    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (alertView.tag == 200) {
        switch (buttonIndex) {
            case 0:{
                return;
            }
                break;
            case 1:{
                [[[HLogin sharedInstance]logout]subscribeNext:^(id x) {
                    //退出登录 将保存的用户信息清除
//                    [[[UserDefault alloc] init] clearUserData];
                    self.model = nil;
                    
                }];
                
            }
                break;
            default:
                break;
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
